//
// Created by sjjmw on 3/24/2022.
//

//应该使用dfs

#include "iostream"
#include "vector"
#include "list"
#include "algorithm"
#include "string"
#include "unordered_map"
#include "cmath"
#include<iomanip>
#include "string"
#include "map"
#include "list"
struct Sol{
//    std::vector<Range> ranges;
std::vector<int> flz;
std::vector<char> puted;
//std::vector<char> maxv;
int need_cnt;
bool putable(int x){
    if(puted[x]){
        return false;
    }
    int x1=x-1;
    if(x1<0){
        x1+=flz.size();
    }
    if(puted[x1]){
        return false;
    }
    x1=x+1;
    x1%=puted.size();
    if(puted[x1]){
        return false;
    }
    return true;
}
int max=-1;
void dfs(int tree_cnt,int begin,int mgd){
    if(tree_cnt==need_cnt){
        if(mgd>max){
            max=mgd;

        }
        return;
    }
    for(int i=begin;i<flz.size();i+=1){
        if(putable(i)){
            puted[i]=1;
            dfs(tree_cnt+1,i+2,mgd+flz[i]);
            puted[i]=0;
        }
    }
}
    void handle(
            int n,int b
            ){
        flz.resize(n);
        puted.resize(n);
        for(int i=0;i<n;i++){
            std::cin>>flz[i];
        }
        need_cnt=b;
        dfs(0,0,0);
        if(max==-1){
            printf("Error!\n");
            return;
        }
        printf("%d\n",max);
        ;
    }
};
int main(){
    int a,b,c;
//    float a,b,c,d;
    int e;
    while(std::cin>>a>>b){
        Sol().handle(a,b);
    }

    return 0;
}